const { formatErrorJson } = require('../../../utils/retUtil');

module.exports = async (ctx, next) => {

    try {
        console.log('middleware/checkPermission');
        ctx.body = {
            title: 'koa2 json by middleware/errorHandler'
        };
        console.log('middleware/errorHandler after ');
        await next();
        console.log('middleware/errorHandler after yield next');
    } catch (error) {
        ctx.body = formatErrorJson(error);
    }
};